//
//  ViewController.m
//  备忘录模式
//
//  Created by flannery on 2018/12/19.
//  Copyright © 2018年 flannery. All rights reserved.
//

#import "ViewController.h"
#import "Originator.h"
#import "CareTaker.h"
#import "Memento.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    Originator *originator = Originator.new;
    CareTaker *careTaker = CareTaker.new;
    
    [originator setState:@"State #1"];
    [originator setState:@"State #2"];
    [careTaker add:[originator saveStateToMemento]];
    [originator setState:@"State #3"];
    [careTaker add:[originator saveStateToMemento]];
    [originator setState:@"State #4"];
    
    NSLog(@"Current State: %@", [originator getState]);
    [originator getStateFromMemento:[careTaker get:0]];
    NSLog(@"First saved State: %@", [originator getState]);
    [originator getStateFromMemento:[careTaker get:1]];
    NSLog(@"Second saved State: %@", [originator getState]);
}


@end
